@import '../../../variables';

$spacer: $s;

// MAIN LAYOUT
// -----------
:host {
  flex-grow: 1;
  max-width: $side-nav-width;
  width: $side-nav-width;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  // mobile viewport bug fix
  min-height: -webkit-fill-available;

  ::ng-deep .mat-menu-item mat-icon {
    margin-bottom: 2px;
  }
}

@media (min-width: $side-nav-width-switch-l) {
  :host {
    max-width: $side-nav-width-l;
    width: $side-nav-width-l;
  }
}

:host {
  a,
  button {
    height: 44px !important;
    line-height: 44px !important;
  }

  a {
    color: rgba(var(--palette-foreground-text), var(--palette-foreground-text-alpha));

    @include darkTheme() {
      color: rgba(
        var(--palette-foreground-text-dark),
        var(--palette-foreground-text-dark-alpha)
      );
    }
  }
}

section {
  display: flex;
  flex-direction: column;
}

.main {
  margin-bottom: $spacer;
  padding-bottom: $spacer;

  :host-context(.isMac.isElectron) & {
    padding-top: $mac-title-bar-padding;
  }

  &:after {
    bottom: 0;
  }
}

.app {
  margin-top: auto;
  padding-top: $spacer;

  &:after {
    top: 0;
  }
}

.main,
.tags,
.app {
  position: relative;

  &:after {
    @include dividerBorderColor();
    content: '';
    position: absolute;
    left: $s * 2;
    right: $s * 2;
    height: 0;
  }
}

.tags,
.projects {
  margin-bottom: $spacer;
  padding-bottom: $spacer;
}

// LIST-ITEMS
// ----------
.tag,
.project {
  display: flex;
  position: relative;
  align-items: stretch;
  justify-content: stretch;

  button .badge {
    display: none;
  }

  &.hasTasks {
    button .badge {
      display: block;
      z-index: 10;
      position: absolute;
      line-height: 1;
      left: $s;
      width: 40px;
      text-align: center;
      top: 50%;
      transform: translateY(-50%);
      font-size: 10px;
      padding: 1px 0 0;
      border: 1px solid $light-theme-extra-border-color;
      background: #fff;
      border-radius: $card-border-radius;

      // avoid affecting drag handle
      pointer-events: none;

      @include darkTheme() {
        border-color: $dark-theme-extra-border-color;
        background: $dark-theme-bg-lighter;
      }
    }
  }

  &.isHidden {
    display: none !important;
  }

  button:first-of-type {
    flex-grow: 1;
  }

  button:last-of-type {
    border-radius: 0;
    align-self: stretch;
    display: block;
    height: auto;
    min-width: 48px;

    @include mq(xs) {
      opacity: 0;
      display: none;
    }
  }

  &:focus,
  &:hover {
    button:last-of-type {
      opacity: 0.8;
      display: block;
    }
  }
}

// color bar left styles
.tag,
.project,
.route-link {
  .tag-color,
  .project-color,
  &.isActiveRoute:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: $s * 0.5;
    background-color: $c-primary;
  }

  .tag-color,
  .project-color {
    opacity: 0;
  }

  &.isActiveContext,
  &:focus,
  &:hover {
    .tag-color,
    .project-color {
      opacity: 1;
    }
  }
}

.tag-settings-btn,
.tag button:first-of-type,
.project-settings-btn,
.project button:first-of-type,
.route-link {
  &:focus,
  &:hover {
    font-weight: bold;

    @include lightTheme {
      background: rgba(
        var(--palette-background-hover),
        var(--palette-background-hover-alpha, 1)
      );
    }
    @include darkTheme {
      background: rgba(255, 255, 255, 0.1);
    }
  }
}

.route-link.isActiveRoute,
.tag.isActiveContext,
.project.isActiveContext {
  background-color: mat-css-color-primary(500, 0.04);
}

.route-link.isActiveRoute,
.tag.isActiveContext button,
.project.isActiveContext button {
  font-weight: bold;
}

.route-link.isActiveRoute,
.route-link.isActiveRoute mat-icon,
.tag.isActiveContext mat-icon,
.tag.isActiveContext button,
.project.isActiveContext mat-icon,
.project.isActiveContext button {
  // does not look good for dark theme...
  @include lightTheme {
    color: $c-primary-800;
  }
}

// OTHER-ITEMS
// ----------

.expand-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;

  &:focus,
  &:hover {
    @include darkTheme {
      background: rgba(255, 255, 255, 0.1);
    }
    @include lightTheme {
      background: rgba(
        var(--palette-background-hover),
        var(--palette-background-hover-alpha, 1)
      );
    }
  }

  ::ng-deep mat-icon:last-of-type {
    margin-left: auto;
    margin-right: 0;
    transition: $transition-standard;
  }

  &.isExpanded ::ng-deep mat-icon:last-of-type {
    transform: rotate(180deg);
  }
}

.scroll-down-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;

  ::ng-deep mat-icon:last-of-type {
    margin-left: auto;
    margin-right: 0;
  }
}

.drag-handle {
  /* Firefox 1.5-26 */
  position: relative;
  @include grabCursor();

  &:after {
    content: '';
    position: absolute;
    top: -$s;
    left: -$s;
    right: -$s;
    bottom: -$s;
  }
}

.no-tags-info {
  padding: 4px 16px;
  font-style: italic;
  opacity: 0.7;
}
